<?php
/* Initialize Joomla framework */
define( '_JEXEC', 1 );
define('JPATH_BASE', str_replace('/cron','',dirname(__FILE__)) );
define( 'DS', DIRECTORY_SEPARATOR );
/* Required Files */
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
/* To use Joomla's Database Class */
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'factory.php' );
/* Create the Application */
$mainframe =& JFactory::getApplication('site');
/* Create a database object */
$db =& JFactory::getDBO();
//die('++');
//
/* Create a table called cron with one column `datetime` */
$query = 'CREATE TABLE IF NOT EXISTS '.$db->nameQuote('#__cron').' '
.'(`datetime` DATETIME)';
$db->setQuery($query);
$db->query();
/* Die on error */
if($db->getErrorMsg()) {
	die($db->getErrorMsg());
}
$query = 'INSERT INTO '.$db->nameQuote('#__cron').' (`datetime`) VALUES ("2011-01-01 23:59:49")';
$db->setQuery($query);
$db->query();
/* Update the cron table with the current date and time */
$query = 'UPDATE '.$db->nameQuote('#__cron').' SET datetime = "'.date('Y-m-d H:i:s',time()).'"';
$db->setQuery($query);
$db->query();
